import turtle
import math

# 创建一个窗口和画笔
screen = turtle.Screen()
screen.bgcolor("black")
screen.tracer(0)  # 关闭自动刷新以提高性能

pen = turtle.Turtle()
pen.speed(0)
pen.color("white")

# 动态螺旋动画
angle = 0
radius = 0

while True:
    pen.clear()  # 清除之前的绘图
    
    # 更新参数
    angle += 0.1
    radius += 0.1
    
    # 移动到起始点
    x = radius * math.cos(angle)
    y = radius * math.sin(angle)
    pen.penup()
    pen.goto(x, y)
    pen.pendown()
    
    # 绘制彩色螺旋
    for i in range(100):
        pen.color(
            (math.sin(angle + i * 0.1) + 1) / 2,
            (math.cos(angle + i * 0.1) + 1) / 2,
            (math.sin(angle * 2 + i * 0.1) + 1) / 2
        )
        pen.forward(i * 2)
        pen.right(91)
    
    screen.update()  # 手动刷新屏幕